package Newsblog;
//12.16牛客小白月赛第一题
import java.util.Scanner;
//提高课可持续化字典树

/**
 * @author :chenjie
 * @date :Created 2022/12/16 19:21
 */
public class TheMinimumWeightOFASubsequence {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[]arr=new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }int x=arr[0];
        for (int i = 1; i < n; i++) {
            x=x&arr[i];
        }
        System.out.println(x);
    }
}
